define :startinstr do
  name = params[:name]
  init = params[:init]
  zkep = "#{node[:zookeeper][:ip]}:#{node[:zookeeper][:port]}"  
  
  chef_gem "zk" do
    action :install
  end
 
  ruby_block "instrument start of #{name} (#{node[:zookeeper][:ip]})" do
    block do            
      require 'zk'
      require 'json'
      
      begin
        i_url = node[:client][:status]
        z = ZK.new(zkep)
        if init or not z.exists?(i_url) 
        #if not z.exists?(i_url) 
          wsInfo = []
        else
          wsInfo = JSON.parse(z.get(i_url).first)
        end
        wsInfo << {:stage => name, :start => Time.now.to_i}
        z.create(i_url, wsInfo.to_json, {:or => :set})
      ensure
        z.close
      end
    end
  end  
end
